package com.bjesc_b2c.app.appraiset.mvp.model.impl;

import android.content.Context;

import com.bjesc_b2c.app.appraiset.http.IApiActivityRequest;
import com.bjesc_b2c.app.appraiset.mvp.model.AddCarModel;
import com.rxretrofit_build.util.MapUtil;

import java.util.HashMap;

import master_bean.BasicInfoBean;
import rxretrofit_base.model.ShowType;
import rxretrofit_base.model.TokenBean;
import rxretrofit_base.net.BaseSubscriber;
import rxretrofit_base.net.RxRequest;

/**
 * Created by lenovo on 2017/4/21.
 */

public class AddCarModelImpl implements AddCarModel {
    private CallBack callBack;
    public AddCarModelImpl(CallBack callBack){
        this.callBack = callBack;
    }
    @Override
    public void requestAddCarId(Context context, BasicInfoBean bean) {
        HashMap<String, Object> build = new MapUtil()
                .put("check_area_id",bean.getCheck_area_id())
                .put("vin_number",bean.getVin_number())
                .build();
        RxRequest.request(ShowType.SHOW, RxRequest.getClient(context, build).create(IApiActivityRequest.class).addCar(),
                new BaseSubscriber<TokenBean<BasicInfoBean>>(context) {
                    @Override
                    public void onSuccess(TokenBean<BasicInfoBean> o) {
                        if(callBack!=null){
                            callBack.callback(o.getData());
                        }
                    }

                    @Override
                    public void onFailure(Throwable e) {

                    }
                });


    }
        public interface CallBack{
            void callback(BasicInfoBean bean);
        }
}
